From b173c373787f560ebf87507325424a215137fbe8 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 15 Feb 2006 00:37:15 +0100 Subject: [PATCH] Fix to previous changeset: CLTS must be unconditional in setup_fpu(), as the flag can be set in CR0 even if the VCPU has already dirtied the FPU (this happens if a paravirtualised guest has set CR0.TS). Signed-off-by: Keir Fraser --- xen/include/asm-x86/i387.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/xen/include/asm-x86/i387.h b/xen/include/asm-x86/i387.h index fa9ba43e90..a324af013f 100644 --- a/xen/include/asm-x86/i387.h +++ b/xen/include/asm-x86/i387.h @@ -15,25 +15,26 @@ #include extern void init_fpu(void); -extern void save_init_fpu(struct vcpu *tsk); -extern void restore_fpu(struct vcpu *tsk); +extern void save_init_fpu(struct vcpu *v); +extern void restore_fpu(struct vcpu *v); -#define unlazy_fpu(_tsk) do { \ - if ( test_bit(_VCPUF_fpu_dirtied, &(_tsk)->vcpu_flags) ) \ - save_init_fpu(_tsk); \ +#define unlazy_fpu(v) do { \ + if ( test_bit(_VCPUF_fpu_dirtied, &(v)->vcpu_flags) ) \ + save_init_fpu(v); \ } while ( 0 ) -#define load_mxcsr( val ) do { \ - unsigned long __mxcsr = ((unsigned long)(val) & 0xffbf); \ - __asm__ __volatile__ ( "ldmxcsr %0" : : "m" (__mxcsr) ); \ +#define load_mxcsr(val) do { \ + unsigned long __mxcsr = ((unsigned long)(val) & 0xffbf); \ + __asm__ __volatile__ ( "ldmxcsr %0" : : "m" (__mxcsr) ); \ } while ( 0 ) -/* Make domain the FPU owner */ static inline void setup_fpu(struct vcpu *v) { + /* Avoid recursion. */ + clts(); + if ( !test_and_set_bit(_VCPUF_fpu_dirtied, &v->vcpu_flags) ) { - clts(); if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) ) restore_fpu(v); else -- 2.30.2